home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Franz PD / Franz PD Disk #067 (1990-04)(Amiga User Group Deutschland e.V.).zip / Franz PD Disk #067 (1990-04)(Amiga User Group Deutschland e.V.).adf / Source.zip / Pascal.i < prev    next >
Text File  |  1989-11-26  |  6KB  |  222 lines

  1.  
  2. {
  3.     Pascal.i (of PCQ Pascal)
  4.     Copyright (c) 1989 Patrick Quaid.
  5.  
  6.     These are the constants, types and variables required
  7. for the compiler.
  8.  
  9. }
  10.  
  11.  
  12. CONST
  13.  
  14.     Hash_Size    = 255;        { Size of the Hash Table - 1 }
  15.     literalsize    = 8000;        { room for character literals }
  16.  
  17.     eqsize        = 127;        { size of the error buffer }
  18.  
  19.     BufferSize    = 2048;        { size of Input buffer }
  20.     BufferMax    = BufferSize - 1; { Last index in Buffer }
  21.  
  22.     Spell_Max    = 10000;    { Size of the spelling records }
  23.  
  24. {
  25.     These are the symbols.  Note that the first 40 or so
  26. correspond to the appropriate entries in the Reserved array.
  27. }
  28.  
  29. TYPE
  30.     Symbols = (and1, array1, begin1, by1, case1,
  31.         const1, div1, do1, downto1, else1, end1, extern1,
  32.         file1, for1, forward1, func1, goto1, if1, in1,
  33.         label1, mod1, not1, of1, or1, packed1, private1,
  34.         proc1, program1, record1, repeat1, return1, set1,
  35.         shl1, shr1, then1, to1, type1, until1, var1, while1,
  36.         with1, xor1,
  37.  
  38.         ident1, numeral1, asterisk1, becomes1, colon1,
  39.         comma1, dotdot1, endtext1, equal1, greater1,
  40.         leftbrack1, leftparent1, less1, minus1,
  41.         notequal1, notgreater1, notless1, period1, plus1,
  42.         rightbrack1, rightparent1, semicolon1, leftcurl1,
  43.         rightcurl1, quote1, apostrophe1, carat1, at1, pound1,
  44.         ampersand1, realdiv1, realnumeral1, unknown1, Char1);
  45.  
  46. CONST
  47.     LastReserved = Xor1;
  48.  
  49. TYPE
  50.  
  51.     TypeObject = (ob_array, ob_set, ob_record, ob_ordinal, ob_pointer,
  52.          ob_enumer, ob_subrange, ob_synonym, ob_file, ob_real);
  53.  
  54.     TypeRec = Record
  55.     Next    : ^TypeRec;
  56.     Object  : TypeObject;
  57.     SubType    : ^TypeRec;
  58.     Ref    : Address; { An IDPtr to record fields, or
  59.                  a TypePtr to the index type of an array }
  60.     Upper,
  61.     Lower    : Integer;
  62.     Size    : Integer;
  63.     end;
  64.     TypePtr = ^TypeRec;
  65.  
  66.     IDObject = (global, local, refarg, valarg, proc, func, obtype, field,
  67.         stanproc, stanfunc, constant, pending_type, typed_const,
  68.         lab);
  69.  
  70.     IDStorage = (st_none, st_external, st_internal, st_private, st_initialized,
  71.          st_forward);
  72.  
  73.     IDRec = Record
  74.     Next    : ^IDRec;
  75.     Name    : String;
  76.     Object    : IDObject;
  77.     VType    : TypePtr;
  78.     Param    : ^IDRec;
  79.     Level    : Short;
  80.     Storage    : IDStorage;
  81.     Offset    : Integer;
  82.     Unique    : Integer;
  83.     end;
  84.     IDPtr = ^IDRec;
  85.  
  86.     BlockRec = Record
  87.     Previous : ^BlockRec;
  88.     FirstType: TypePtr;
  89.     Level     : Short;
  90.     Table     : Array [0..Hash_Size] of IDPtr;
  91.     end;
  92.     BlockPtr = ^BlockRec;
  93.  
  94. { The following record allows me to nest include calls to the
  95.   limits of memory. }
  96.  
  97.     FileRec = Record
  98.     PCQFile    : Text;
  99.     Previous: ^FileRec;
  100.     SaveLine,
  101.     SaveStart : Integer;
  102.     SaveChar  : Char;
  103.     Name    : String;
  104.     end;
  105.     FileRecPtr = ^FileRec;
  106.  
  107. { The next record saves the names of include files so I won't load
  108.   them twice.  Note that only as much of the record as is required
  109.   for a particular file name is allocated. }
  110.  
  111.     IncludeRec = record
  112.     Next : ^IncludeRec;
  113.     Name : Array [0..100] of Char;
  114.     end;
  115.     IncludeRecPtr = ^IncludeRec;
  116.  
  117. { This next record helps implement the With statement.  For each active
  118.   with statement, there is a corresponding record.  These are stacked
  119.   (to handle scoping), and simply contain a pointer to the proper type. }
  120.  
  121.     WithRec = Record
  122.           Previous : ^WithRec;
  123.           RecType  : TypePtr;
  124.           Offset   : Integer;
  125.           end;
  126.     WithRecPtr = ^WithRec;
  127.  
  128. {    This is the spelling table stuff.  Originally I was allocating
  129.     memory for ID names one at a time, then freeing them at the end of
  130.     a procedure definition.  I was probably wasting too much time allocating
  131.     memory, however, so I switched back to a one-big-array method, although
  132.     this is somewhat more flexible than the 1.0 version. }
  133.  
  134. TYPE
  135.     SpellRec = Record
  136.            Previous : ^SpellRec;
  137.            First : Integer; { The first index held in this record }
  138.            Data  : Array [0..Spell_Max] of Char;
  139.            end;
  140.     SpellRecPtr = ^SpellRec;
  141.  
  142. VAR
  143.  
  144. {
  145.     These are the global variables for the compiler.
  146. When this file is included by the main program, space is
  147. allocated for the variables.  The external files, although
  148. they also import this file, just generate external
  149. references.
  150. }
  151.  
  152.     CurrentBlock    : BlockPtr;
  153.  
  154. { Space for literal strings and arrays in the program text }
  155.  
  156.     LitQ        : Array [0..LiteralSize] of Char;
  157.     LitPtr        : Integer;
  158.  
  159. { The reserved words, held here in order to make searching quicker }
  160.  
  161.     Reserved    : Array [And1..LastReserved] of String;
  162.  
  163. { These four implement the error queue, which prints out the latest
  164. 128 chars or two lines, whichever is less, when an error occurs }
  165.  
  166.     ErrorQ        : Array [1..EQSize] of Char;
  167.     EQStart        : Short;
  168.     EQEnd        : Short;
  169.     ErrorPtr    : Short;
  170.  
  171. { The spelling table variables }
  172.  
  173.     CurrentSpellRec : SpellRecPtr;
  174.     SpellPtr    : Integer;
  175.  
  176. { The With variables }
  177.  
  178.     FirstWith,
  179.     LastWith    : WithRecPtr;
  180.     StackLoad    : Integer;
  181.  
  182. { Many of these are named similar to the vars in Small-C, but watch
  183. out for different meanings. }
  184.  
  185.     StandardStorage    : IDStorage;    { The default storage mode }
  186.     NxtLab        : Integer;    { Just the current label }
  187.     LitLab        : Integer;    { Label of the literals }
  188.     StackSpace    : Integer;    { Counts local var stack space }
  189.     ErrorCount    : Integer;    { Literally the # of errors }
  190.     InFile        : FileRecPtr;    { The current input record }
  191.     OutFile        : Text;        { The main assembly output }
  192.     MainMode    : Boolean;    { Is this a program file? }
  193.     IncludeList    : IncludeRecPtr;{ list of include files }
  194.     FnStart        : Integer;    { The line # of the start of this }
  195.     LineNo        : Integer;    { Current line number. }
  196.  
  197.     CurrFn        : IDPtr;    { Index of current proc or func }
  198.     BadType,            { Universal type index }
  199.     IntType,            { These are just pointers to }
  200.     BoolType,            { the appropriate types }
  201.     RealType,
  202.     CharType,
  203.     TextType,
  204.     StringType,
  205.     AddressType,
  206.     ShortType,
  207.     ByteType,
  208.     LiteralType    : TypePtr;    { Temp type for array lits }
  209.     CurrSym        : Symbols;    { Current symbol }
  210.     SymLoc        : Integer;    { Literal integer }
  211.     RealValue    : Real;        { Literal float }
  212.     SymText        : String;    { Holds ident. text }
  213.     CurrentChar    : Char;        { The current char! }
  214.     BuffedChar    : Char;        { Buffered character }
  215.     CharBuffed    : Boolean;    { is a char buffered? }
  216.     RangeCheck    : Boolean;    { Doing rangechecks? }
  217.     IOCheck        : Boolean;    { Doing IO checks? }
  218.     Inform        : Boolean;    { Verbose updates? }
  219.     MainName    : String;    { Main file name }
  220.     OutName        : String;    { The output file name }
  221.     TypeID        : IDPtr;    { Points to a type's ID rec }
  222.